/**
 * @author: 野狼上校
 * @create: 2024-03-28 23:11
 * @version: 1.0
 *
 * 角色相关的请求
 */
import instance, {RespResult} from "@/api/index.ts"


/*分页查询角色数据*/
export const getRolesByPage = (data: any): Promise<RespResult> => {
    return instance({
        url: `/auth/role/getRolesByPage`,
        method: "get",
        params: data
    })
}

/*根据Id删除角色*/
export const deleteRoleById = (id: number): Promise<RespResult> => {
    return instance({
        url: `/auth/role/${id}`,
        method: "delete"
    })
}

/*新增*/
export const addRole = (data: any): Promise<RespResult> => {
    return instance({
        url: `/auth/role`,
        method: "post",
        data: data
    })
}

/*修改*/
export const editRole = (data: any): Promise<RespResult> => {
    return instance({
        url: `/auth/role`,
        method: "put",
        data: data
    })
}

/*查询所有的角色*/
export const getAllRoles = (): Promise<RespResult> => {
    return instance({
        url:`/auth/role/getRoles`,
        method: "get"
    })
}

/*给角色设置菜单*/
export const setMenus = (data:any): Promise<RespResult> => {
    return instance({
        url:`/auth/role/setMenus`,
        method: "get",
        params: data
    })
}

/*给角色设置资源*/
export const setResources = (data:any): Promise<RespResult> => {
    return instance({
        url:`/auth/role/setResources`,
        method: "get",
        params: data
    })
}